/**
 * @param {number} n
 * @return {number}
 */
var tribonacci = function(n) {
    if(n == 0) return 0
    if(n == 1 || n == 2) return 1
    const cns = [0, 1, 1]
    for(let i = 3; i <= n; i++) {
        let temp = cns[0] + cns[1] + cns[2]
        cns[0] = cns[1]
        cns[1] = cns[2]
        cns[2] = temp 
    }
    return cns[2]
};
console.log(tribonacci(25));